/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.sys.entity;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.jeesite.common.PropertyMsg;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.BaseEntity;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.entity.Extend;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.utils.excel.fieldtype.CompanyType;
import com.jeesite.common.utils.excel.fieldtype.OfficeType;
import com.jeesite.common.utils.excel.fieldtype.SubjectType;
import com.jeesite.modules.edu.entity.EduIndustry;
import com.jeesite.modules.edu.entity.EduProfessionalTitle;
import com.jeesite.modules.edu.entity.EduSubject;
import com.jeesite.modules.edu.entity.EduTalent;
import com.jeesite.modules.edu.entity.EduTeacherState;
import com.jeesite.modules.edu.entity.EduTeacherTitle;
import com.jeesite.modules.edu.entity.EduTwoOrganization;
import com.jeesite.modules.sys.utils.EmpUtils;

/**
 * 员工管理Entity
 * @author ThinkGem
 * @version 2017-03-25
 */
@Table(name="${_prefix}sys_employee", alias="a", columns={
		@Column(includeEntity=BaseEntity.class),
		@Column(includeEntity=DataEntity.class),
		@Column(name="submit_status", 	attrName="submitStatus",label="提交状态"),		
		@Column(name="emp_code", 	attrName="empCode", 			label="员工编码", isPK=true),
		@Column(name="emp_name", 	attrName="empName", 			label="员工姓名", queryType=QueryType.LIKE),
		@Column(name="emp_name_en", attrName="empNameEn", 			label="英文名", queryType=QueryType.LIKE),
		@Column(name="office_code", attrName="office.officeCode", 	label="院校编码", isQuery=false),
		@Column(name="office_name", attrName="office.officeName", 	label="供职院校", isQuery=false),
		@Column(name="company_code", attrName="company.companyCode", label="院校编码", isQuery=false),
		@Column(name="company_name", attrName="company.companyName", label="毕业名称", isQuery=false),
		@Column(name="state", attrName="state", label="教师状态"),
		@Column(name="highest_edu", attrName="highestEdu", label="最高学历"),
		@Column(name="highest_degree", attrName="highestDegree", label="最高学位"),
		@Column(name="is_postdoctor", attrName="isPostdoctor", label="博士后", comment="博士后是:1,否:0"),
		@Column(name="learning_situation", attrName="learningSituation", label="国（境）外学习情", comment="国（境）外学习情况"),
		@Column(name="learning_situation_ext", attrName="learningSituationExt", label="国（境）外学习情", comment="国（境）外学习情况"),
		@Column(name="student_level", attrName="studentLevel", label="学生层次", comment="教授学生层次(硕士及以上:0,硕士:1,硕士及本科:2,本科:3,本科及专科:4,专科:5)"),
		@Column(name="mentor", attrName="mentor", label="担任导师", comment="担任导师(博导:0,硕导:1,博导/硕导:2,不担任导师:3)"),
		@Column(name="school_job", attrName="schoolJob", label="学校兼职"),
		@Column(name="school_job_ext", attrName="schoolJobExt", label="学校名称"),
		@Column(name="industry_job", attrName="industryJob", label="企业兼职"),
		@Column(name="industry_job_ext", attrName="industryJobExt", label="企业信息"),
		@Column(name="work_job", attrName="workJob", label="国（境）外工作情况", comment="国（境）外工作情况"),
		@Column(name="work_job_ext", attrName="workJobExt", label="国（境）外工作情况", comment="国（境）外工作情况"),
		@Column(name="subject_major_id", attrName="subjectMajor.dictCode", label="所学专业"),
		@Column(name="subject_major_name", attrName="subjectMajor.dictLabel", label="所学专业"),
		@Column(name="subject_id", attrName="subject.dictCode", label="学科门类"),
		@Column(name="subject_name", attrName="subject.dictLabel", label="学科门类"),
		@Column(name="subject_research_id", attrName="subjectResearch.dictCode", label="本人专研"),
		@Column(name="subject_research_name", attrName="subjectResearch.dictLabel", label="本人专研"),
		@Column(name="teacher_id", attrName="eduTeacherTitle.teacherId", label="教师职称"),
		@Column(name="teacher_name", attrName="eduTeacherTitle.teacherName", label="教师职称"),
		@Column(name="professional_id", attrName="eduProfessionalTitle.professionalId", label="专业职称"),
		@Column(name="professional_name", attrName="eduProfessionalTitle.professionalName", label="专业职称"),
		@Column(name="industry_id", attrName="eduIndustry.treeCode", label="国民经济"),
		@Column(name="industry_name", attrName="eduIndustry.treeName", label="国民经济"),
		@Column(name="two_organization_code", attrName="eduTwoOrganization.dictCode", label="二级机构编码"),
		@Column(name="two_organization_label", attrName="eduTwoOrganization.dictLabel", label="二级机构名称"),
		@Column(name="organization", attrName="organization", label="所在内设机构职务"),
		@Column(name="op", attrName="op", label="修改内容"),
		@Column(name="industry_name", attrName="eduIndustry.treeName", label="国民经济"),
	}, joinTable={
		@JoinTable(type=Type.LEFT_JOIN, entity=Office.class, alias="o", 
			on="o.office_code = a.office_code",
			columns={@Column(includeEntity=Office.class)}),
		@JoinTable(type=Type.LEFT_JOIN, entity=Company.class, alias="c", 
			on="c.company_code = a.company_code",
			columns={@Column(includeEntity=Company.class)}),
		@JoinTable(type=Type.LEFT_JOIN, entity=Area.class, alias="ar",
			on="ar.area_code = c.area_code", attrName="company.area",
			columns={
				@Column(name="area_name", label="区域名称"),
				@Column(name="area_type", label="区域类型"),
		}),
		@JoinTable(type=Type.LEFT_JOIN, entity=EduSubject.class, attrName="subjectMajor", alias="m1",
		on="m1.dict_code = a.subject_major_id", columns={
			@Column(name="dict_code", label="所学专业专业编码", isPK=true),
			@Column(name="dict_label", label="所学专业专业名称", isQuery=false),
			@Column(name="tree_names", label="完整名称", isQuery=false),
	}),
		@JoinTable(type=Type.LEFT_JOIN, entity=EduTwoOrganization.class, attrName="eduTwoOrganization", alias="eto",
		on="eto.dict_code = a.two_organization_code", columns={
			@Column(name="dict_code", label="二级机构编码", isPK=true),
			@Column(name="dict_label", label="二级机构名称", isQuery=false),
		}),
	@JoinTable(type=Type.LEFT_JOIN, entity=EduSubject.class, attrName="subject", alias="m2",
	on="m2.dict_code = a.subject_id", columns={
		@Column(name="dict_code", label="学科门类编码", isPK=true),
		@Column(name="dict_label", label="学科门类名称", isQuery=false),
		@Column(name="tree_names", label="学科门类完整名称", isQuery=false),
	}),
	@JoinTable(type=Type.LEFT_JOIN, entity=EduSubject.class, attrName="subjectResearch", alias="m3",
	on="m3.dict_code = a.subject_research_id", columns={
		@Column(name="dict_code", label="本人专研编码", isPK=true),
		@Column(name="dict_label", label="本人专研名称", isQuery=false),
		@Column(name="tree_names", label="本人专研完整名称", isQuery=false),
	}),
	@JoinTable(type=Type.LEFT_JOIN, entity=EduTeacherTitle.class, attrName="eduTeacherTitle", alias="t1",
	on="t1.teacher_id = a.teacher_id", columns={
		@Column(name="teacher_id", label="职称编码", isPK=true),
		@Column(name="teacher_name", label="教师职称", isQuery=false),
		@Column(name="tree_names", label="完整名称", isQuery=false),
	}),
	@JoinTable(type=Type.LEFT_JOIN, entity=EduProfessionalTitle.class, attrName="eduProfessionalTitle", alias="p1",
	on="p1.professional_id = a.professional_id", columns={
			@Column(name="professional_id", label="职称编码", isPK=true),
			@Column(name="professional_name", label="专业职称", isQuery=false),
			@Column(name="tree_names", label="完整名称", isQuery=false),
	}),
	@JoinTable(type=Type.LEFT_JOIN, entity=EduIndustry.class, attrName="eduIndustry", alias="i1",
	on="i1.tree_code = a.industry_id", columns={
		@Column(name="tree_code", label="国民经济编码", isPK=true),
		@Column(name="tree_name", label="国民经济名称", isQuery=false),
		@Column(name="tree_names", label="国民经济完整名称", isQuery=false),
	}),
	

}, orderBy="a.update_date DESC"
)
public class Employee extends DataEntity<Employee> {
	
	private static final long serialVersionUID = 1L;
	private String submitStatus;
    @PropertyMsg("员工编码")
	private String empCode;		// 员工编码
    @PropertyMsg("员工姓名")
	private String empName;		// 员工姓名
    @PropertyMsg("员工英文名")
	private String empNameEn;	// 员工英文名
    @PropertyMsg(value="供职院校",fieldType=OfficeType.class,className = "OfficeType")
	private Office office;		// 机构编码
    @PropertyMsg(value="毕业院校",fieldType=CompanyType.class,className = "CompanyType")
	private Company company;	// 公司编码
    @PropertyMsg("职位")
	private String postCode;	// 根据职位查询
  
	private List<EmployeePost> employeePostList = ListUtils.newArrayList(); // 关联岗位信息
	@PropertyMsg(value="状态",dictType="teacher_state")
	private String state;//教师在职状态标注 00:在职 01:调出 02:离职 03:退休等
	@PropertyMsg(value="最高学历",dictType="highest_edu")
	private String highestEdu;		// 最高学历
	@PropertyMsg(value="所学专业",fieldType=SubjectType.class,className = "SubjectType")
	private EduSubject subjectMajor;		// 所学专业
	@PropertyMsg(value="最高学历",dictType="highest_degree")
	private String highestDegree;		// 最高学位
	@PropertyMsg("是否博士后")
	private String isPostdoctor;		// 博士后是:1,否:0
	@PropertyMsg(value="国（境）外学习情况",dictType="school_abroad")
	private String learningSituation;		// 国（境）外学习情况
	@PropertyMsg("学习情况")
	private String learningSituationExt;
	@PropertyMsg("教师职称")
	private EduTeacherTitle eduTeacherTitle;		// 教师职称
	@PropertyMsg("专业职称")
	private EduProfessionalTitle eduProfessionalTitle;		// 专业职称
	@PropertyMsg(value="教授学生层次",dictType="sys_student_level")
	private String studentLevel;		// 教授学生层次(硕士及以上:0,硕士:1,硕士及本科:2,本科:3,本科及专科:4,专科:5)
	@PropertyMsg("所学专业")
	private EduSubject subject;		// 所学专业
	@PropertyMsg(value="担任导师",dictType="sys_mentor")
	private String mentor;		// 担任导师(博导:0,硕导:1,博导/硕导:2,不担任导师:3)
	@PropertyMsg("本人专研")
	private EduSubject subjectResearch;		// 本人专研
	@PropertyMsg("专业研究")
	private EduIndustry eduIndustry;		// 专业研究
	@PropertyMsg(value="其他学校兼职",dictType="school_job")
	private String schoolJob;		// 其他学校兼职
	@PropertyMsg("兼职学校名称")
	private String schoolJobExt;		// 其他学校兼职

	@PropertyMsg(value="行业企业兼职",dictType="industry_job")
	private String industryJob;		// 行业企业兼职
	@PropertyMsg("企业信息")
	private String industryJobExt;		// 企业信息
	@PropertyMsg(value="国（境）外工作情况",dictType="work_abroad")
	private String workJob;		// 国（境）外工作情况
	@PropertyMsg("国（境）外工作情况描述")
	private String workJobExt;		// 国（境）外工作情况
	@PropertyMsg("所在二级机构名称")
	private EduTwoOrganization eduTwoOrganization;//所在二级机构名称
	@PropertyMsg("所在内设机构职务")
	private String organization;//所在内设机构职务
	private String op;//所在内设机构职务
	private List<EduTalent> testDataChildList = ListUtils.newArrayList();
	private List<EduTeacherState> teacherStateChildList = ListUtils.newArrayList();
	
	private String action;
	
	
	public String getOp() {
		return op;
	}

	public void setOp(String op) {
		this.op = op;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public Employee() {
		this(null);
	}

	public Employee(String id){
		super(id);
	}
	
	public String getSubmitStatus() {
		return submitStatus;
	}

	public void setSubmitStatus(String submitStatus) {
		this.submitStatus = submitStatus;
	}

	public String getEmpCode() {
		return empCode;
	}

	public void setEmpCode(String empCode) {
		this.empCode = empCode;
	}
	
	@Length(min=0, max=100, message="名称长度不能超过 100 个字符")
	public String getEmpName() {
		return empName;
	}

	public void setEmpName(String empName) {
		this.empName = empName;
	}
	
	@Length(min=0, max=100, message="英文名长度不能超过 100 个字符")
	public String getEmpNameEn() {
		return empNameEn;
	}

	public void setEmpNameEn(String empNameEn) {
		this.empNameEn = empNameEn;
	}

	@NotNull(message="供职院校不能为空")
	public Office getOffice() {
		if (office == null){
			office = new Office();
		}
		return office;
	}

	public void setOffice(Office office) {
		this.office = office;
	}

	@NotNull(message="毕业院校不能为空")
	public Company getCompany() {
		if (company == null){
			company = new Company();
		}
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public String getPostCode() {
		return postCode;
	}

	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}

	public List<EmployeePost> getEmployeePostList() {
		return employeePostList;
	}
	
	public void setEmployeePostList(List<EmployeePost> employeePostList) {
		this.employeePostList = employeePostList;
	}

	public String[] getEmployeePosts() {
		List<String> list = ListUtils.extractToList(employeePostList, "postCode");
		return list.toArray(new String[list.size()]);
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getHighestEdu() {
		return highestEdu;
	}

	public void setHighestEdu(String highestEdu) {
		this.highestEdu = highestEdu;
	}

	public EduSubject getSubjectMajor() {
		return subjectMajor;
	}

	public void setSubjectMajor(EduSubject subjectMajor) {
		this.subjectMajor = subjectMajor;
	}

	public String getHighestDegree() {
		return highestDegree;
	}

	public void setHighestDegree(String highestDegree) {
		this.highestDegree = highestDegree;
	}

	public String getIsPostdoctor() {
		return isPostdoctor;
	}

	public void setIsPostdoctor(String isPostdoctor) {
		this.isPostdoctor = isPostdoctor;
	}

	public String getLearningSituation() {
		return learningSituation;
	}

	public void setLearningSituation(String learningSituation) {
		this.learningSituation = learningSituation;
	}

	public EduTeacherTitle getEduTeacherTitle() {
		return eduTeacherTitle;
	}

	public void setEduTeacherTitle(EduTeacherTitle eduTeacherTitle) {
		this.eduTeacherTitle = eduTeacherTitle;
	}

	public EduProfessionalTitle getEduProfessionalTitle() {
		return eduProfessionalTitle;
	}

	public void setEduProfessionalTitle(EduProfessionalTitle eduProfessionalTitle) {
		this.eduProfessionalTitle = eduProfessionalTitle;
	}

	public String getStudentLevel() {
		return studentLevel;
	}

	public void setStudentLevel(String studentLevel) {
		this.studentLevel = studentLevel;
	}

	public EduSubject getSubject() {
		return subject;
	}

	public void setSubject(EduSubject subject) {
		this.subject = subject;
	}

	public String getMentor() {
		return mentor;
	}

	public void setMentor(String mentor) {
		this.mentor = mentor;
	}

	public EduSubject getSubjectResearch() {
		return subjectResearch;
	}

	public void setSubjectResearch(EduSubject subjectResearch) {
		this.subjectResearch = subjectResearch;
	}

	public EduIndustry getEduIndustry() {
		return eduIndustry;
	}

	public void setEduIndustry(EduIndustry eduIndustry) {
		this.eduIndustry = eduIndustry;
	}

	public String getSchoolJob() {
		return schoolJob;
	}

	public void setSchoolJob(String schoolJob) {
		this.schoolJob = schoolJob;
	}

	public String getIndustryJob() {
		return industryJob;
	}

	public void setIndustryJob(String industryJob) {
		this.industryJob = industryJob;
	}

	public String getWorkJob() {
		return workJob;
	}

	public void setWorkJob(String workJob) {
		this.workJob = workJob;
	}

	public List<EduTalent> getTestDataChildList() {
		return testDataChildList;
	}

	public void setTestDataChildList(List<EduTalent> testDataChildList) {
		this.testDataChildList = testDataChildList;
	}

	public void setEmployeePosts(String[] employeePosts) {
		for (String val : employeePosts){
			if (StringUtils.isNotBlank(val)){
				EmployeePost e = new EmployeePost();
				e.setPostCode(val);
				this.employeePostList.add(e);
			}
		}
	}


	public EduTwoOrganization getEduTwoOrganization() {
		return eduTwoOrganization;
	}

	public void setEduTwoOrganization(EduTwoOrganization eduTwoOrganization) {
		this.eduTwoOrganization = eduTwoOrganization;
	}

	public String getOrganization() {
		return organization;
	}

	public void setOrganization(String organization) {
		this.organization = organization;
	}

	public String getIndustryJobExt() {
		return industryJobExt;
	}

	public void setIndustryJobExt(String industryJobExt) {
		this.industryJobExt = industryJobExt;
	}
	
	

	public String getDetail() {
		Office office = getOffice();
		if (!org.springframework.util.StringUtils.isEmpty(office)
				&& !org.springframework.util.StringUtils.isEmpty(office.getOfficeName())) {
			StringBuffer sb = new StringBuffer(office.getOfficeName());
			sb.append("/");
			office = EmpUtils.getOffice(office.getOfficeCode());
			
			if(!org.springframework.util.StringUtils.isEmpty(office)) {
				Extend ext = office.getExtend();
				if(!org.springframework.util.StringUtils.isEmpty(ext)) {
					if(!org.springframework.util.StringUtils.isEmpty(ext.getExtendS2())) {
						sb.append(ext.getExtendS2());
						sb.append("/");
					}
					if(!org.springframework.util.StringUtils.isEmpty(ext.getExtendS3())) {
						sb.append(ext.getExtendS3());
						sb.append("/");
					}
					if(!org.springframework.util.StringUtils.isEmpty(ext.getExtendS4())) {
						sb.append(ext.getExtendS4());
						sb.append("/");
					}
				}
			}
			
			String str = sb.toString();
			if(str.length() == (str.lastIndexOf("/")+1)) {
				str = str.substring(0,str.length()-1);
			}
			return str;
		}
		return "";
	}

	

	public String getSchoolJobExt() {
		return schoolJobExt;
	}

	public void setSchoolJobExt(String schoolJobExt) {
		this.schoolJobExt = schoolJobExt;
	}

	public String getLearningSituationExt() {
		return learningSituationExt;
	}

	public void setLearningSituationExt(String learningSituationExt) {
		this.learningSituationExt = learningSituationExt;
	}

	public String getWorkJobExt() {
		return workJobExt;
	}

	public void setWorkJobExt(String workJobExt) {
		this.workJobExt = workJobExt;
	}

	public List<EduTeacherState> getTeacherStateChildList() {
		return teacherStateChildList;
	}

	public void setTeacherStateChildList(List<EduTeacherState> teacherStateChildList) {
		this.teacherStateChildList = teacherStateChildList;
	}

	
}